\input{settings.sty}
\usepackage{Sweave}

 
\begin{document}
\vspace*{2cm}
\begin{center}
{\Large Parameter Table}\\
~\\
\today\\
~\\
Tim Bergsma\\
\end{center}
\newpage

\section{Purpose}
This script picks up after model.Rnw to process bootstrap results and make a parameter table. It assumes the current working directory is the script directory containing this file.
\subsection{Package}
\begin{Schunk}
\begin{Sinput}
> library(metrumrg)
\end{Sinput}
\end{Schunk}
\section{inputs}
`wikitab' gives us a quick synthesis of `rlog' and the `lookup' of wiki notation in 1005.ctl.
We do some science on the result first, and then some aesthetics for printing in a \LaTeX table.  Table \ref{p1005}.
\begin{Schunk}
\begin{Sinput}
> tab <- wikitab(1005,'../nonmem')
> tab$estimate <- signif(as.numeric(tab$estimate),3)
> tab$tool <- NULL
> tab$run <- NULL
> tab$se <- NULL
> tab
\end{Sinput}
\begin{Soutput}
   parameter                                   description
1     THETA1                       apparent oral clearance
2     THETA2                central volume of distribution
3     THETA3                      absorption rate constant
4     THETA4                  intercompartmental clearance
5     THETA5             peripheral volume of distribution
6     THETA6                      male effect on clearance
7     THETA7                    weight effect on clearance
8   OMEGA1.1      interindividual variability of clearance
9   OMEGA2.1   interindividual clearance-volume covariance
10  OMEGA2.2 interindividual variability of central volume
11  OMEGA3.1       interindividual clearance-Ka covariance
12  OMEGA3.2          interindividual volume-Ka covariance
13  OMEGA3.3             interindividual variability of Ka
14  SIGMA1.1                            proportional error
15  SIGMA2.2                                additive error
                                                               model estimate
1  CL/F (L/h) ~ theta_1 * theta_6 ^MALE * (WT/70)^theta_7  * e^eta_1   9.5100
2                         V_c /F (L) ~ theta_2 * (WT/70)^1 * e^eta_2  22.8000
3                                    K_a (h^-1 ) ~ theta_3 * e^eta_3   0.0714
4                                                Q/F (L/h) ~ theta_4   3.4700
5                                               V_p /F (L) ~ theta_5 113.0000
6                                                MALE_CL/F ~ theta_6   1.0200
7                                                  WT_CL/F ~ theta_7   1.1900
8                                               IIV_CL/F ~ Omega_1.1   0.2140
9                                               cov_CL,V ~ Omega_2.1   0.1210
10                                            IIV_V_c /F ~ Omega_2.2   0.0945
11                                            cov_CL,Ka  ~ Omega_3.1  -0.0116
12                                             cov_V,Ka  ~ Omega_3.2  -0.0372
13                                              IIV_K_a  ~ Omega_3.3   0.0466
14                                              err_prop ~ Sigma_1.1   0.0492
15                                               err_add ~ Sigma_2.2   0.2020
   prse
1  9.75
2  9.55
3  7.35
4  15.4
5    21
6  11.1
7  28.3
8  22.8
9  26.4
10 33.2
11  173
12 36.1
13 34.8
14 10.9
15 33.5
\end{Soutput}
\end{Schunk}
Now we can extract some information from the model statements.
\begin{Schunk}
\begin{Sinput}
> tab$units <- justUnits(tab$model)
> tab$model <- noUnits(tab$model)
> tab$name <- with(tab, wiki2label(model))
> tab[c('model','units','name')]
\end{Sinput}
\begin{Soutput}
                                                          model units      name
1  CL/F  ~ theta_1 * theta_6 ^MALE * (WT/70)^theta_7  * e^eta_1   L/h      CL/F
2                       V_c /F  ~ theta_2 * (WT/70)^1 * e^eta_2     L     V_c/F
3                                      K_a  ~ theta_3 * e^eta_3 h^-1        K_a
4                                                Q/F  ~ theta_4   L/h       Q/F
5                                             V_p /F  ~ theta_5     L     V_p/F
6                                           MALE_CL/F ~ theta_6       MALE_CL/F
7                                             WT_CL/F ~ theta_7         WT_CL/F
8                                          IIV_CL/F ~ Omega_1.1        IIV_CL/F
9                                          cov_CL,V ~ Omega_2.1        cov_CL,V
10                                       IIV_V_c /F ~ Omega_2.2       IIV_V_c/F
11                                       cov_CL,Ka  ~ Omega_3.1       cov_CL,Ka
12                                        cov_V,Ka  ~ Omega_3.2        cov_V,Ka
13                                         IIV_K_a  ~ Omega_3.3         IIV_K_a
14                                         err_prop ~ Sigma_1.1        err_prop
15                                          err_add ~ Sigma_2.2         err_add
\end{Soutput}
\end{Schunk}
\section{variance}
The estimates for the matrix diagonals are variances, and their square roots have special meaning.  In model 1005, interindividual variability was modelled exponentially, in which case square root of variance gives an approximate CV; alternatively, and exact CV can be calculated.  For proportional error terms like ERR1, square root gives an exact CV.  For additive error terms like ERR2, square root gives standard deviation.

We can use functions of `parameter' to sort out the various error components, as they are used in this model. 
\subsection{exponential}
\begin{Schunk}
\begin{Sinput}
> expo <- is.iiv(tab$parameter) & is.diagonal(tab$parameter)
> tab$parameter[expo]
\end{Sinput}
\begin{Soutput}
[1] "OMEGA1.1" "OMEGA2.2" "OMEGA3.3"
\end{Soutput}
\begin{Sinput}
> tab$cv[expo] <- cvLognormal(tab$estimate[expo])
> tab[,c('parameter','name','estimate','cv')]
\end{Sinput}
\begin{Soutput}
   parameter      name estimate        cv
1     THETA1      CL/F   9.5100        NA
2     THETA2     V_c/F  22.8000        NA
3     THETA3       K_a   0.0714        NA
4     THETA4       Q/F   3.4700        NA
5     THETA5     V_p/F 113.0000        NA
6     THETA6 MALE_CL/F   1.0200        NA
7     THETA7   WT_CL/F   1.1900        NA
8   OMEGA1.1  IIV_CL/F   0.2140 0.4884902
9   OMEGA2.1  cov_CL,V   0.1210        NA
10  OMEGA2.2 IIV_V_c/F   0.0945 0.3148161
11  OMEGA3.1 cov_CL,Ka  -0.0116        NA
12  OMEGA3.2  cov_V,Ka  -0.0372        NA
13  OMEGA3.3   IIV_K_a   0.0466 0.2184098
14  SIGMA1.1  err_prop   0.0492        NA
15  SIGMA2.2   err_add   0.2020        NA
\end{Soutput}
\end{Schunk}
\subsection{proportional}
\begin{Schunk}
\begin{Sinput}
> writeLines(read.nmctl('../nonmem/ctl/1005.ctl')$err)
\end{Sinput}
\begin{Soutput}
 Y=F*(1+ERR(1)) + ERR(2)
 IPRE=F
;<doc>
\end{Soutput}
\begin{Sinput}
> prop <- is.random(tab$parameter) & tab$name %contains% 'prop'
> tab$parameter[prop]
\end{Sinput}
\begin{Soutput}
[1] "SIGMA1.1"
\end{Soutput}
\begin{Sinput}
> tab$cv[prop] <- sqrt(tab$estimate[prop])
> tab[,c('parameter','name','estimate','cv')]
\end{Sinput}
\begin{Soutput}
   parameter      name estimate        cv
1     THETA1      CL/F   9.5100        NA
2     THETA2     V_c/F  22.8000        NA
3     THETA3       K_a   0.0714        NA
4     THETA4       Q/F   3.4700        NA
5     THETA5     V_p/F 113.0000        NA
6     THETA6 MALE_CL/F   1.0200        NA
7     THETA7   WT_CL/F   1.1900        NA
8   OMEGA1.1  IIV_CL/F   0.2140 0.4884902
9   OMEGA2.1  cov_CL,V   0.1210        NA
10  OMEGA2.2 IIV_V_c/F   0.0945 0.3148161
11  OMEGA3.1 cov_CL,Ka  -0.0116        NA
12  OMEGA3.2  cov_V,Ka  -0.0372        NA
13  OMEGA3.3   IIV_K_a   0.0466 0.2184098
14  SIGMA1.1  err_prop   0.0492 0.2218107
15  SIGMA2.2   err_add   0.2020        NA
\end{Soutput}
\end{Schunk}
\subsection{additive}
\begin{Schunk}
\begin{Sinput}
> add <- is.residual(tab$parameter) & tab$name %contains% 'add'
> tab$parameter[add]
\end{Sinput}
\begin{Soutput}
[1] "SIGMA2.2"
\end{Soutput}
\begin{Sinput}
> tab$sd[add] <- sqrt(tab$estimate[add])
> tab[,c('parameter','name','estimate','cv','sd')]
\end{Sinput}
\begin{Soutput}
   parameter      name estimate        cv        sd
1     THETA1      CL/F   9.5100        NA        NA
2     THETA2     V_c/F  22.8000        NA        NA
3     THETA3       K_a   0.0714        NA        NA
4     THETA4       Q/F   3.4700        NA        NA
5     THETA5     V_p/F 113.0000        NA        NA
6     THETA6 MALE_CL/F   1.0200        NA        NA
7     THETA7   WT_CL/F   1.1900        NA        NA
8   OMEGA1.1  IIV_CL/F   0.2140 0.4884902        NA
9   OMEGA2.1  cov_CL,V   0.1210        NA        NA
10  OMEGA2.2 IIV_V_c/F   0.0945 0.3148161        NA
11  OMEGA3.1 cov_CL,Ka  -0.0116        NA        NA
12  OMEGA3.2  cov_V,Ka  -0.0372        NA        NA
13  OMEGA3.3   IIV_K_a   0.0466 0.2184098        NA
14  SIGMA1.1  err_prop   0.0492 0.2218107        NA
15  SIGMA2.2   err_add   0.2020        NA 0.4494441
\end{Soutput}
\end{Schunk}
\section{covariance}
The estimates of matrix off-diagonals are covariances, and are more useful if transformed to correlations.  We could extract the matrices manually, or use package shortcuts.
\begin{Schunk}
\begin{Sinput}
> cor <- omegacor(run=1005,project='../nonmem')
> cor
\end{Sinput}
\begin{Soutput}
           [,1]       [,2]       [,3]
[1,]  1.0000000  0.8494444 -0.1165179
[2,]  0.8494444  1.0000000 -0.5608629
[3,] -0.1165179 -0.5608629  1.0000000
\end{Soutput}
\begin{Sinput}
> half(cor)
\end{Sinput}
\begin{Soutput}
       1.1        2.1        2.2        3.1        3.2        3.3 
 1.0000000  0.8494444  1.0000000 -0.1165179 -0.5608629  1.0000000 
\end{Soutput}
\begin{Sinput}
> offdiag(half(cor))
\end{Sinput}
\begin{Soutput}
       2.1        3.1        3.2 
 0.8494444 -0.1165179 -0.5608629 
\end{Soutput}
\begin{Sinput}
> off <- is.iiv(tab$parameter) & is.offdiagonal(tab$parameter)
> tab$parameter[off]
\end{Sinput}
\begin{Soutput}
[1] "OMEGA2.1" "OMEGA3.1" "OMEGA3.2"
\end{Soutput}
\begin{Sinput}
> tab$cor[off] <- offdiag(half(cor))
> tab[,c('parameter','name','estimate','cv','sd','cor')]
\end{Sinput}
\begin{Soutput}
   parameter      name estimate        cv        sd        cor
1     THETA1      CL/F   9.5100        NA        NA         NA
2     THETA2     V_c/F  22.8000        NA        NA         NA
3     THETA3       K_a   0.0714        NA        NA         NA
4     THETA4       Q/F   3.4700        NA        NA         NA
5     THETA5     V_p/F 113.0000        NA        NA         NA
6     THETA6 MALE_CL/F   1.0200        NA        NA         NA
7     THETA7   WT_CL/F   1.1900        NA        NA         NA
8   OMEGA1.1  IIV_CL/F   0.2140 0.4884902        NA         NA
9   OMEGA2.1  cov_CL,V   0.1210        NA        NA  0.8494444
10  OMEGA2.2 IIV_V_c/F   0.0945 0.3148161        NA         NA
11  OMEGA3.1 cov_CL,Ka  -0.0116        NA        NA -0.1165179
12  OMEGA3.2  cov_V,Ka  -0.0372        NA        NA -0.5608629
13  OMEGA3.3   IIV_K_a   0.0466 0.2184098        NA         NA
14  SIGMA1.1  err_prop   0.0492 0.2218107        NA         NA
15  SIGMA2.2   err_add   0.2020        NA 0.4494441         NA
\end{Soutput}
\end{Schunk}
\section{confidence interval}
We wish to include 95 percentiles in our table as confidence intervals.
\begin{Schunk}
\begin{Sinput}
> boot <- read.csv('../nonmem/1005bootlog.csv',as.is=TRUE)
> head(boot)
\end{Sinput}
\begin{Soutput}
  X tool run parameter   moment            value
1 1  nm7   1       ofv  minimum 2459.17577212358
2 2  nm7   1    THETA1 estimate          9.90624
3 3  nm7   1    THETA1     prse             <NA>
4 4  nm7   1    THETA1       se             <NA>
5 5  nm7   1    THETA2 estimate          21.8851
6 6  nm7   1    THETA2     prse             <NA>
\end{Soutput}
\begin{Sinput}
> boot <- boot[boot$moment=='estimate',]
> boot <- data.frame(cast(boot,...~moment))
> head(boot)
\end{Sinput}
\begin{Soutput}
   X tool run parameter  estimate
1  2  nm7   1    THETA1   9.90624
2  5  nm7   1    THETA2   21.8851
3  8  nm7   1    THETA3 0.0708172
4 11  nm7   1    THETA4   3.36908
5 14  nm7   1    THETA5   94.6441
6 17  nm7   1    THETA6  0.972458
\end{Soutput}
\begin{Sinput}
> boot <- boot[,c('run','parameter','estimate')]
> sapply(boot,class)
\end{Sinput}
\begin{Soutput}
        run   parameter    estimate 
  "integer" "character"    "factor" 
\end{Soutput}
\begin{Sinput}
> boot$estimate <- as.numeric(as.character(boot$estimate))
> unique(boot$parameter)
\end{Sinput}
\begin{Soutput}
 [1] "THETA1"   "THETA2"   "THETA3"   "THETA4"   "THETA5"   "THETA6"  
 [7] "THETA7"   "OMEGA1.1" "OMEGA2.1" "OMEGA2.2" "OMEGA3.1" "OMEGA3.2"
[13] "OMEGA3.3" "SIGMA1.1" "SIGMA2.1" "SIGMA2.2"
\end{Soutput}
\begin{Sinput}
> quan <- function(x,probs)as.character(signif(quantile(x,probs=probs,na.rm=TRUE),3))
> boot$lo <- with(boot, reapply(estimate,parameter,quan,probs=.05))
> boot$hi <- with(boot, reapply(estimate,parameter,quan,probs=.95))
> head(boot)
\end{Sinput}
\begin{Soutput}
  run parameter   estimate     lo     hi
1   1    THETA1  9.9062400   7.31   11.1
2   1    THETA2 21.8851000   19.2   27.9
3   1    THETA3  0.0708172 0.0625 0.0838
4   1    THETA4  3.3690800   2.78   4.91
5   1    THETA5 94.6441000   85.6    559
6   1    THETA6  0.9724580  0.847   1.25
\end{Soutput}
\begin{Sinput}
> boot <- unique(boot[,c('parameter','lo','hi')])
> boot
\end{Sinput}
\begin{Soutput}
   parameter      lo       hi
1     THETA1    7.31     11.1
2     THETA2    19.2     27.9
3     THETA3  0.0625   0.0838
4     THETA4    2.78     4.91
5     THETA5    85.6      559
6     THETA6   0.847     1.25
7     THETA7    0.61     1.91
8   OMEGA1.1   0.128    0.321
9   OMEGA2.1  0.0606    0.183
10  OMEGA2.2   0.047    0.158
11  OMEGA3.1 -0.0448   0.0261
12  OMEGA3.2 -0.0577 -0.00491
13  OMEGA3.3  0.0236   0.0811
14  SIGMA1.1  0.0399   0.0587
15  SIGMA2.1       0        0
16  SIGMA2.2  0.0836    0.329
\end{Soutput}
\begin{Sinput}
> boot$ci <- with(boot, parens(glue(lo,',',hi)))
> boot
\end{Sinput}
\begin{Soutput}
   parameter      lo       hi                 ci
1     THETA1    7.31     11.1        (7.31,11.1)
2     THETA2    19.2     27.9        (19.2,27.9)
3     THETA3  0.0625   0.0838    (0.0625,0.0838)
4     THETA4    2.78     4.91        (2.78,4.91)
5     THETA5    85.6      559         (85.6,559)
6     THETA6   0.847     1.25       (0.847,1.25)
7     THETA7    0.61     1.91        (0.61,1.91)
8   OMEGA1.1   0.128    0.321      (0.128,0.321)
9   OMEGA2.1  0.0606    0.183     (0.0606,0.183)
10  OMEGA2.2   0.047    0.158      (0.047,0.158)
11  OMEGA3.1 -0.0448   0.0261   (-0.0448,0.0261)
12  OMEGA3.2 -0.0577 -0.00491 (-0.0577,-0.00491)
13  OMEGA3.3  0.0236   0.0811    (0.0236,0.0811)
14  SIGMA1.1  0.0399   0.0587    (0.0399,0.0587)
15  SIGMA2.1       0        0              (0,0)
16  SIGMA2.2  0.0836    0.329     (0.0836,0.329)
\end{Soutput}
\begin{Sinput}
> tab <- stableMerge(tab,boot[,c('parameter','ci')])
> tab
\end{Sinput}
\begin{Soutput}
   parameter                                   description
1     THETA1                       apparent oral clearance
2     THETA2                central volume of distribution
3     THETA3                      absorption rate constant
4     THETA4                  intercompartmental clearance
5     THETA5             peripheral volume of distribution
6     THETA6                      male effect on clearance
7     THETA7                    weight effect on clearance
8   OMEGA1.1      interindividual variability of clearance
9   OMEGA2.1   interindividual clearance-volume covariance
10  OMEGA2.2 interindividual variability of central volume
11  OMEGA3.1       interindividual clearance-Ka covariance
12  OMEGA3.2          interindividual volume-Ka covariance
13  OMEGA3.3             interindividual variability of Ka
14  SIGMA1.1                            proportional error
15  SIGMA2.2                                additive error
                                                          model estimate prse
1  CL/F  ~ theta_1 * theta_6 ^MALE * (WT/70)^theta_7  * e^eta_1   9.5100 9.75
2                       V_c /F  ~ theta_2 * (WT/70)^1 * e^eta_2  22.8000 9.55
3                                      K_a  ~ theta_3 * e^eta_3   0.0714 7.35
4                                                Q/F  ~ theta_4   3.4700 15.4
5                                             V_p /F  ~ theta_5 113.0000   21
6                                           MALE_CL/F ~ theta_6   1.0200 11.1
7                                             WT_CL/F ~ theta_7   1.1900 28.3
8                                          IIV_CL/F ~ Omega_1.1   0.2140 22.8
9                                          cov_CL,V ~ Omega_2.1   0.1210 26.4
10                                       IIV_V_c /F ~ Omega_2.2   0.0945 33.2
11                                       cov_CL,Ka  ~ Omega_3.1  -0.0116  173
12                                        cov_V,Ka  ~ Omega_3.2  -0.0372 36.1
13                                         IIV_K_a  ~ Omega_3.3   0.0466 34.8
14                                         err_prop ~ Sigma_1.1   0.0492 10.9
15                                          err_add ~ Sigma_2.2   0.2020 33.5
   units      name        cv        sd        cor                 ci
1    L/h      CL/F        NA        NA         NA        (7.31,11.1)
2      L     V_c/F        NA        NA         NA        (19.2,27.9)
3  h^-1        K_a        NA        NA         NA    (0.0625,0.0838)
4    L/h       Q/F        NA        NA         NA        (2.78,4.91)
5      L     V_p/F        NA        NA         NA         (85.6,559)
6        MALE_CL/F        NA        NA         NA       (0.847,1.25)
7          WT_CL/F        NA        NA         NA        (0.61,1.91)
8         IIV_CL/F 0.4884902        NA         NA      (0.128,0.321)
9         cov_CL,V        NA        NA  0.8494444     (0.0606,0.183)
10       IIV_V_c/F 0.3148161        NA         NA      (0.047,0.158)
11       cov_CL,Ka        NA        NA -0.1165179   (-0.0448,0.0261)
12        cov_V,Ka        NA        NA -0.5608629 (-0.0577,-0.00491)
13         IIV_K_a 0.2184098        NA         NA    (0.0236,0.0811)
14        err_prop 0.2218107        NA         NA    (0.0399,0.0587)
15         err_add        NA 0.4494441         NA     (0.0836,0.329)
\end{Soutput}
\end{Schunk}
\section{aesthetics}
Here we format the table for printing.
\begin{Schunk}
\begin{Sinput}
> tab$name <- NULL
> tab$parameter <- NULL
> tab$model <- wiki2latex(tab$model)
> tab$estimate <- as.character(tab$estimate)
> tab$estimate <- paste(tab$estimate,'$', tab$units,'$')
> tab$units <- NULL
\end{Sinput}
\end{Schunk}
Note that no parameter defines more than one of CV, SD,and COR.  We could collapse these into a single column, and add a descriptive flag.
\begin{Schunk}
\begin{Sinput}
> m <- as.matrix(tab[,c('cv','sd','cor')])
> tab$variability <- suppressWarnings(apply(m,1,max,na.rm=TRUE))
> tab$variability[is.infinite(tab$variability)] <- NA
> i <- is.defined(m)
> i[!i] <- NA
> tab$statistic <- apply(i,1,function(x){
+   p <- colnames(i)[x]
+   ifelse(all(is.na(p)),NA,p[!is.na(p)])
+ })
> toPercent <- with(tab, !is.na(statistic) & statistic=='cv')
> tab$variability[toPercent] <- percent(tab$variability[toPercent])
> tab$variability <- as.character(signif(tab$variability,3))
> tab$statistic <- map(tab$statistic,from=c(NA,'cv','cor','sd'),to=c(NA,'\\%CV','CORR','SD'))
> tab$variability <- paste(tab$statistic,tab$variability,sep=' = ')
> tab$variability[is.na(tab$statistic)] <- NA
> tab$statistic <- NULL
> tab$cv <- NULL
> tab$sd <- NULL
> tab$cor <- NULL
\end{Sinput}
\end{Schunk}
\begin{table}[!htpb]
 \caption[Model 1005 Parameters]{Parameter Estimates from Population Pharmacokinetic Model Run 1005 \label{p1005}}
 \begin{center}
  \begin{tabular}{llllll}
    \hline \hline
   description & model & estimate & prse & ci & variability \\ \hline
   apparent oral clearance                       & $\mathrm{CL/F  \sim \theta_{1}\cdot \theta_{6}^{MALE}\cdot (WT/70)^{\theta_{7}}\cdot e^{\eta_{1}}}$ & 9.51 $ L/h $     & 9.75 & (7.31,11.1)        &  \\
   central volume of distribution                & $\mathrm{V_{c}/F  \sim \theta_{2}\cdot (WT/70)^{1}\cdot e^{\eta_{2}}}$                                 & 22.8 $ L $       & 9.55 & (19.2,27.9)        &  \\
   absorption rate constant                      & $\mathrm{K_{a} \sim \theta_{3}\cdot e^{\eta_{3}}}$                                                      & 0.0714 $ h^-1  $ & 7.35 & (0.0625,0.0838)    &  \\
   intercompartmental clearance                  & $\mathrm{Q/F  \sim \theta_{4}}$                                                                           & 3.47 $ L/h $     & 15.4 & (2.78,4.91)        &  \\
   peripheral volume of distribution             & $\mathrm{V_{p}/F  \sim \theta_{5}}$                                                                       & 113 $ L $        & 21   & (85.6,559)         &  \\
   male effect on clearance                      & $\mathrm{MALE_{CL/F}\sim \theta_{6}}$                                                                     & 1.02 $  $        & 11.1 & (0.847,1.25)       &  \\
   weight effect on clearance                    & $\mathrm{WT_{CL/F}\sim \theta_{7}}$                                                                       & 1.19 $  $        & 28.3 & (0.61,1.91)        &  \\
   interindividual variability of clearance      & $\mathrm{IIV_{CL/F}\sim \Omega_{1.1}}$                                                                    & 0.214 $  $       & 22.8 & (0.128,0.321)      & \%CV = 48.8  \\
   interindividual clearance-volume covariance   & $\mathrm{cov_{CL,V}\sim \Omega_{2.1}}$                                                                    & 0.121 $  $       & 26.4 & (0.0606,0.183)     & CORR = 0.849  \\
   interindividual variability of central volume & $\mathrm{IIV_{V_{c}/F}\sim \Omega_{2.2}}$                                                                 & 0.0945 $  $      & 33.2 & (0.047,0.158)      & \%CV = 31.5  \\
   interindividual clearance-Ka covariance       & $\mathrm{cov_{CL,Ka} \sim \Omega_{3.1}}$                                                                  & -0.0116 $  $     & 173  & (-0.0448,0.0261)   & CORR = -0.117 \\
   interindividual volume-Ka covariance          & $\mathrm{cov_{V,Ka} \sim \Omega_{3.2}}$                                                                   & -0.0372 $  $     & 36.1 & (-0.0577,-0.00491) & CORR = -0.561 \\
   interindividual variability of Ka             & $\mathrm{IIV_{K_{a}}\sim \Omega_{3.3}}$                                                                   & 0.0466 $  $      & 34.8 & (0.0236,0.0811)    & \%CV = 21.8  \\
   proportional error                            & $\mathrm{err_{prop}\sim \Sigma_{1.1}}$                                                                    & 0.0492 $  $      & 10.9 & (0.0399,0.0587)    & \%CV = 22.2  \\
   additive error                                & $\mathrm{err_{add}\sim \Sigma_{2.2}}$                                                                     & 0.202 $  $       & 33.5 & (0.0836,0.329)     & SD = 0.449    \\ \hline
  \end{tabular}
 \end{center}
\end{table}\section{simple parameter table}
We can make a quick parameter table that does not use wikitab markup. Table \ref{simple}.
\begin{Schunk}
\begin{Sinput}
> tab <- rlog(1005,'../nonmem',tool='nm7',file=NULL)
> head(tab)
\end{Sinput}
\begin{Soutput}
  tool  run parameter   moment            value
1  nm7 1005       ofv  minimum 2405.91626140177
2  nm7 1005    THETA1 estimate          9.50789
3  nm7 1005    THETA1     prse             9.75
4  nm7 1005    THETA1       se          0.92708
5  nm7 1005    THETA2 estimate           22.791
6  nm7 1005    THETA2     prse             9.55
\end{Soutput}
\begin{Sinput}
> tab$tool <- NULL
> tab$run <- NULL
> tab <- tab[tab$moment %in% c('estimate','prse'),]
> unique(tab$parameter)
\end{Sinput}
\begin{Soutput}
 [1] "THETA1"   "THETA2"   "THETA3"   "THETA4"   "THETA5"   "THETA6"  
 [7] "THETA7"   "OMEGA1.1" "OMEGA2.1" "OMEGA2.2" "OMEGA3.1" "OMEGA3.2"
[13] "OMEGA3.3" "SIGMA1.1" "SIGMA2.1" "SIGMA2.2"
\end{Soutput}
\begin{Sinput}
> tab$value <- signif(as.numeric(tab$value),3)
> tab$parameter <- factor(tab$parameter,levels=unique(tab$parameter))#to preserve row order during cast
> tab <- cast(tab,parameter~moment)
> tab
\end{Sinput}
\begin{Soutput}
   parameter estimate   prse
1     THETA1   9.5100   9.75
2     THETA2  22.8000   9.55
3     THETA3   0.0714   7.35
4     THETA4   3.4700  15.40
5     THETA5 113.0000  21.00
6     THETA6   1.0200  11.10
7     THETA7   1.1900  28.30
8   OMEGA1.1   0.2140  22.80
9   OMEGA2.1   0.1210  26.40
10  OMEGA2.2   0.0945  33.20
11  OMEGA3.1  -0.0116 173.00
12  OMEGA3.2  -0.0372  36.10
13  OMEGA3.3   0.0466  34.80
14  SIGMA1.1   0.0492  10.90
15  SIGMA2.1   0.0000    Inf
16  SIGMA2.2   0.2020  33.50
\end{Soutput}
\begin{Sinput}
> tab$parameter <- parameter2wiki(tab$parameter)
> tab
\end{Sinput}
\begin{Soutput}
    parameter estimate   prse
1    theta_1    9.5100   9.75
2    theta_2   22.8000   9.55
3    theta_3    0.0714   7.35
4    theta_4    3.4700  15.40
5    theta_5  113.0000  21.00
6    theta_6    1.0200  11.10
7    theta_7    1.1900  28.30
8  Omega_1.1    0.2140  22.80
9  Omega_2.1    0.1210  26.40
10 Omega_2.2    0.0945  33.20
11 Omega_3.1   -0.0116 173.00
12 Omega_3.2   -0.0372  36.10
13 Omega_3.3    0.0466  34.80
14 Sigma_1.1    0.0492  10.90
15 Sigma_2.1    0.0000    Inf
16 Sigma_2.2    0.2020  33.50
\end{Soutput}
\begin{Sinput}
> tab$parameter <- wiki2latex(tab$parameter)
> tab
\end{Sinput}
\begin{Soutput}
                   parameter estimate   prse
1    $\\mathrm{\\theta_{1}}$   9.5100   9.75
2    $\\mathrm{\\theta_{2}}$  22.8000   9.55
3    $\\mathrm{\\theta_{3}}$   0.0714   7.35
4    $\\mathrm{\\theta_{4}}$   3.4700  15.40
5    $\\mathrm{\\theta_{5}}$ 113.0000  21.00
6    $\\mathrm{\\theta_{6}}$   1.0200  11.10
7    $\\mathrm{\\theta_{7}}$   1.1900  28.30
8  $\\mathrm{\\Omega_{1.1}}$   0.2140  22.80
9  $\\mathrm{\\Omega_{2.1}}$   0.1210  26.40
10 $\\mathrm{\\Omega_{2.2}}$   0.0945  33.20
11 $\\mathrm{\\Omega_{3.1}}$  -0.0116 173.00
12 $\\mathrm{\\Omega_{3.2}}$  -0.0372  36.10
13 $\\mathrm{\\Omega_{3.3}}$   0.0466  34.80
14 $\\mathrm{\\Sigma_{1.1}}$   0.0492  10.90
15 $\\mathrm{\\Sigma_{2.1}}$   0.0000    Inf
16 $\\mathrm{\\Sigma_{2.2}}$   0.2020  33.50
\end{Soutput}
\end{Schunk}
\begin{table}[!htpb]
 \caption[Simple Parameter Table]{Simple Parameter Table \label{simple}}
 \begin{center}
  \begin{tabular}{lrr}
    \hline \hline
   parameter & estimate & prse \\ \hline
   $\mathrm{\theta_{1}}$   & \verb#9.5100# & \verb#9.75# \\
   $\mathrm{\theta_{2}}$   & \verb#22.8000# & \verb#9.55# \\
   $\mathrm{\theta_{3}}$   & \verb#0.0714# & \verb#7.35# \\
   $\mathrm{\theta_{4}}$   & \verb#3.4700# & \verb#15.40# \\
   $\mathrm{\theta_{5}}$   & \verb#113.0000# & \verb#21.00# \\
   $\mathrm{\theta_{6}}$   & \verb#1.0200# & \verb#11.10# \\
   $\mathrm{\theta_{7}}$   & \verb#1.1900# & \verb#28.30# \\
   $\mathrm{\Omega_{1.1}}$ & \verb#0.2140# & \verb#22.80# \\
   $\mathrm{\Omega_{2.1}}$ & \verb#0.1210# & \verb#26.40# \\
   $\mathrm{\Omega_{2.2}}$ & \verb#0.0945# & \verb#33.20# \\
   $\mathrm{\Omega_{3.1}}$ & \verb#-0.0116# & \verb#173.00# \\
   $\mathrm{\Omega_{3.2}}$ & \verb#-0.0372# & \verb#36.10# \\
   $\mathrm{\Omega_{3.3}}$ & \verb#0.0466# & \verb#34.80# \\
   $\mathrm{\Sigma_{1.1}}$ & \verb#0.0492# & \verb#10.90# \\
   $\mathrm{\Sigma_{2.1}}$ & \verb#0.0000# & \verb#Inf# \\
   $\mathrm{\Sigma_{2.2}}$ & \verb#0.2020# & \verb#33.50# \\ \hline
  \end{tabular}
 \end{center}
\end{table}\end{document}
